package cn.edu.fzu.homemaking.domain.entity;

import java.util.Date;

import com.alibaba.fastjson.annotation.JSONField;

import cn.edu.fzu.homemaking.common.MD5Util;
import cn.edu.fzu.homemaking.domain.enums.SexEnum;
import cn.edu.fzu.homemaking.domain.enums.StatusEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author yifan
 * @date 2023/3/31
 */
@Data
@NoArgsConstructor
public class SysUserSso {

    private Long       id;
    //邮箱
    private String     email;
    //密码
    @JSONField(serialize = false)
    private String     password;
    //姓名
    private String     name;
    //性别
    private SexEnum    sex;
    //出生年月
    @JSONField(format = "yyyy-MM-dd")
    private Date       birth;
    //手机号码
    private String     phone;
    //家庭地址
    private String     address;
    //人脸照片
    private String     faceUrl;
    //状态
    private StatusEnum status;
    //创建时间
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date       createTime;
    //更新时间
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date       updateTime;

    public static SysUserSso build(String email, String password, String name, SexEnum sex, Date birth, String phone,
                                   String address, String faceUrl) {
        SysUserSso user = new SysUserSso();
        user.setEmail(email);
        user.setPassword(MD5Util.MD5Encode(password));
        user.setName(name);
        user.setSex(sex);
        user.setBirth(birth);
        user.setPhone(phone);
        user.setAddress(address);
        user.setFaceUrl(faceUrl);
        user.setStatus(StatusEnum.NORMAL);
        return user;
    }
}
